<template>
	<view>
		<input v-model="email" placeholder="   邮箱" />
		<input v-model="pwd" type="password" placeholder="   密码" />
		<button class="but" @click="loginok">登录</button>
		<view class="register">
			<text class="forget"> 忘记密码</text>
			<text class="account" @click="zhuce"> 注册账户</text>
		</view>
	</view>
</template>

<script>
	import helper from "../../common/helper.js"
	export default {
		data() {
			return {
				email:"",
				pwd:"",
				status:"false"
			}
		},
		methods: {
			loginok(){
				console.log(helper.after)
				helper.after=true,
				helper.before=false,
				console.log(helper.after)
				// uni.switchTab({
				// 	url:"../mine/mine"
				// })
				uni.request({
					url:"https://gljh.utools.club/user/login",
					data:{
						mailaddress:this.email,
						password:this.pwd
					},
					method:"POST",
					success: (res) => {
						if(res.data.message==="success"){
							helper.imgurl=res.data.data.avatar;
							helper.nickName=res.data.data.user.nickName;
							helper.mailaddress=res.data.data.user.mailaddress;
							console.log(res);
							console.log(res.data.data.avatar);
							console.log(res.data.data);
							console.log(res.data.data.user.mailaddress);
							helper.after=true,
							uni.switchTab({
								url:"../mine/mine"
							})
							console.log(helper.after)
						}
						console.log(res.data.message);
						console.log(this.status);
					}
				})
			},
			
			zhuce(){
				uni.redirectTo({
					url:"../register/register"
				})
			}
		}
	}
</script>

<style>
input{
	text-align: left;
	width: 100%;
	height: 60upx;
	border-bottom: #999999 solid 2upx;
}
.but{
	background-color: #55aaff;
	width: 90%;
	margin-top: 20upx;
}

.register{
	display: flex;
	flex-direction: row;
}
.forget{
	color: #007AFF;
	margin-top: 10upx;
	margin-left: 50upx;
}
.account{
	color: #007AFF;
	margin-top: 10upx;
	margin-left: 300upx;
}
</style>
